#ifndef __TRACKER_H__
#define __TRACKER_H__

#include "xx.h"
#include "tools.h"

#define MAX_TRACKER_LEN		1024

#if 0
typedef enum{
	xx_STARTED = 0,
	xx_STOPPED,
	xx_COMPLETED
}xx_STATE;

#endif
struct tracker{
	int					  sockfd;
	char const			* announce; 
	char				* host; 
	char				* port; 
	int					  type;	
	char				* scrape; 

	BOOL				  compact;
	BOOL				  no_peer_id;
//	xx_state			  event;	// started | stopped | completed
	char				  ip[16];
	int					  numwant;			// default 50
	char				  key[21];
	char				  tracker_id[21];	// FIXME: what's the form of tracker_id

	int					  interval;
	int					  min_interval;
};

void *xx_tracker_handler(void * arg);

int xx_tracker_init(xx_torrent *torrent);
int xx_tracker_request();
int xx_tracker_recieve();

int	get_tracker_addr(xx_torrent *torrent);

#endif

